Visual Basic (Declaration) | |
---|---|
Protected Overridable Sub CopyNode2( _ ByVal oldnodedata As NodeType, _ ByVal env As GraphLinksModel(Of NodeType,NodeKey,PortKey,LinkType), _ ByVal newnodedata As NodeType, _ ByVal newgroup As NodeType, _ ByVal newmembers As IEnumerable(Of NodeType) _ ) |
C# | |
---|---|
protected virtual void CopyNode2( NodeType oldnodedata, GraphLinksModel<NodeType,NodeKey,PortKey,LinkType> env, NodeType newnodedata, NodeType newgroup, IEnumerable<NodeType> newmembers ) |
Parameters
- oldnodedata
- the original node data
- env
- the dictionary mapping original objects to copied objects
- newnodedata
- the copied node data
- newgroup
- for convenience, the copied "parent" node data
- newmembers
- for convenience, a list of newly copied member nodes
You will want to override this method if the node data should have any references to copied data. Otherwise the copied node will appear to have links to the original nodes, not to the copied nodes.
Your overridden method may want to do something like what this method does by default: // this assumes the node data has a reference to its container group if (this.GroupNodePath != "" && newgroup != null) { ModifyGroupNodeKey(newnodedata, FindKeyForNode(newgroup)); } // this assumes there's a modifiable collection that InsertMemberNodeKey can work with; // if not, you could instead construct your own list and call ModifyMemberNodeKeys. if (this.MemberNodesPath != "" && newmembers != null) { // remove any old keys; not needed if the copied property value is empty foreach (NodeKey k in FindMemberNodeKeysForNode(newnodedata).OfType<NodeKey>().ToList()) { DeleteMemberNodeKey(newnodedata, k); } // add new keys (which should be different from the old keys) foreach (NodeType newmem in newmembers) { NodeKey newmemkey = FindKeyForNode(newmem); InsertMemberNodeKey(newnodedata, newmemkey); } }